# Maintainer: Robin Candau <antiz@archlinux.org>
# Contributor: Mark Wagie <mark dot wagie at proton dot me>

pkgname=fastfetch
pkgver=2.2.3
pkgrel=1
pkgdesc="Like Neofetch, but much faster because written in C"
arch=('loong64' 'x86_64')
url="https://github.com/fastfetch-cli/fastfetch"
license=('MIT')
depends=('glibc')
makedepends=(
  'chafa'
  'cmake'
  'dbus'
  'dconf'
  'ddcutil'
  'directx-headers'
  'imagemagick'
  'libnm'
  'libpulse'
  'libxcb'
  'libxrandr'
  'mesa'
  'ocl-icd'
  'opencl-headers'
  'pciutils'
  'vulkan-headers'
  'vulkan-icd-loader'
  'wayland'
  'xfconf'
  'zlib'
)
optdepends=(
  'chafa: Image output as ascii art'
  'dbus: Bluetooth, Player & Media detection'
  'dconf: Needed for values that are only stored in DConf + Fallback for GSettings'
  'ddcutil: Brightness detection of external displays'
  'directx-headers: GPU detection in WSL'
  'glib2: Output for values that are only stored in GSettings'
  'imagemagick: Image output using sixel or kitty graphics protocol'
  'libnm: Wifi detection'
  'libpulse: Sound detection'
  'mesa: Needed by the OpenGL module for gl context creation.'
  'libxrandr: Multi monitor support'
  'ocl-icd: OpenCL module'
  'pciutils: GPU output'
  'vulkan-icd-loader: Vulkan module & fallback for GPU output'
  'xfconf: Needed for XFWM theme and XFCE Terminal font'
  'zlib: Faster image output when using kitty graphics protocol'
)
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/${pkgver}.tar.gz")
sha256sums=('dda15a6a73b8e6983d808d3f82567a0e8a333a3fdb53921d88a8bb2d65a38f32')

build() {
	cmake -B build -S "${pkgname}-${pkgver}" \
		-DCMAKE_BUILD_TYPE='None' \
		-DCMAKE_INSTALL_PREFIX='/usr' \
		-DCMAKE_BUILD_TYPE='RelWithDebInfo' \
		-DBUILD_TESTS='ON' \
		-DENABLE_SQLITE3='OFF' \
		-DENABLE_RPM='OFF' \
		-DENABLE_IMAGEMAGICK6='OFF' \
		-DENABLE_DDCUTIL='ON' \
		-Wno-dev
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="${pkgdir}" cmake --install build
}
